package com.kingmed.kmss.common.vo;


import com.kingmed.kmss.common.enums.base.code.ResultCode;

public class CommonResponseHelper {

    public CommonResponseHelper() {
    }

    public static <T> CommonResponse<T> success() {
        CommonResponse response = new CommonResponse();
        response.setCode(ResultCode.SUCCESS.getCode());
        response.setMessage(ResultCode.SUCCESS.getMessage());
        return response;
    }

    public static <T> CommonResponse<T> success(String message) {
        CommonResponse response = new CommonResponse();
        response.setCode(ResultCode.SUCCESS.getCode());
        response.setMessage(message);
        return response;
    }

    public static <T> CommonResponse<T> success(T result) {
        CommonResponse response = new CommonResponse();
        response.setCode(ResultCode.SUCCESS.getCode());
        response.setMessage(ResultCode.SUCCESS.getMessage());
        response.setData(result);
        return response;
    }

    public static <T> CommonResponse<T> success(String message, T result) {
        CommonResponse response = new CommonResponse();
        response.setCode(ResultCode.SUCCESS.getCode());
        response.setMessage(message);
        response.setData(result);
        return response;
    }

    public static <T> CommonResponse<T> fail() {
        CommonResponse response = new CommonResponse();
        response.setCode(ResultCode.FAILED.getCode());
        response.setMessage(ResultCode.FAILED.getMessage());
        return response;
    }


    public static <T> CommonResponse<T> fail(String message) {
        CommonResponse response = new CommonResponse();
        response.setCode(ResultCode.FAILED.getCode());
        response.setMessage(message);
        return response;
    }

    public static <T> CommonResponse<T> fail(T result) {
        CommonResponse response = new CommonResponse();
        response.setCode(ResultCode.FAILED.getCode());
        response.setMessage(ResultCode.FAILED.getMessage());
        response.setData(result);
        return response;
    }

    public static <T> CommonResponse<T> fail(String message, T result) {
        CommonResponse response = new CommonResponse();
        response.setCode(ResultCode.FAILED.getCode());
        response.setMessage(message);
        response.setData(result);
        return response;
    }

    public static <T> CommonResponse<T> forbidden(String message) {
        CommonResponse response = new CommonResponse();
        response.setCode(ResultCode.FORBIDDEN.getCode());
        response.setMessage(message);
        return response;
    }

    public static <T> CommonResponse<T> unauthorized(String message) {
        CommonResponse response = new CommonResponse();
        response.setCode(ResultCode.UNAUTHORIZED.getCode());
        response.setMessage(message);
        return response;
    }

    public static <T> CommonResponse<T> notFound(String message) {
        CommonResponse response = new CommonResponse();
        response.setCode(ResultCode.NOT_FOUND.getCode());
        response.setMessage(message);
        return response;
    }

    public static <T> CommonResponse<T> validateFailed(String message) {
        CommonResponse response = new CommonResponse();
        response.setCode(ResultCode.VALIDATE_FAILED.getCode());
        response.setMessage(message);
        return response;
    }
    public static <T> CommonResponse<T> bpmnFailed(ResultCode resultCode, T result) {
        CommonResponse response = new CommonResponse();
        response.setCode(resultCode.getCode());
        response.setMessage(resultCode.getMessage());
        response.setData(result);
        return response;
    }

}
